<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    
    <link rel="stylesheet" href="../lib/layui/css/layui.css">
    <link href="../lib/fonts/material-icons.css?family=Material+Icons" rel="stylesheet">
    <link href="../lib/css/animate.min.css" rel="stylesheet">
    <link href="../lib/css/quasar.mat.rtl.min.css" rel="stylesheet" type="text/css">
    <!-- yn-tree -->
    <link rel="stylesheet" href="../lib/ynTree/ynTree.css">
    <style>
        .layui-form-checkbox i {
          position: absolute;
          right: 0;
          top: 0;
          width: 30px;
          height: 30px;
          border: 1px solid #d2d2d2;
          border-left: none;
          border-radius: 0 2px 2px 0;
          color: #fff;
          font-size: 20px;
          text-align: center;
        }
        .layui-form-select {
          width: 200px;
          display: inline-block
        }
        *{
			margin: 0;
			padding: 0;
		}
		body{
			font-size: 14px;
			line-height: 1.42857143;
		}
		ul{
			list-style: none;
		}

		.container{
			width: 50%;
			margin: 0 auto;
			padding-top: 50px;
		}
		.fl{
			float: left;
		}
		.fr{
			float: right;
		}
		.clearfix:before,
		.clearfix:after{
			display: table;
			content: " ";
			clear: both;
		}
		.tree{
			margin-left: 20px;
		}

    </style>
</head>
<body>
  <div id="test-stepper">
    <q-stepper v-model="currentStep" ref="supplierInviteStepper" color="primary" contractable>
      <q-step name="supplierInvite" title="供应商邀请">
        
      </q-step>
      <q-step default name="supplierRegiste" title="供应商注册" disable>
        <form class="layui-form" id="addChildTaskForm" action="http://localhost:8080" method="post">
            <textarea style="width:100%;height:210px;" lay-verify="required|number" lay-verType="tips">
                
            </textarea> 
            <!-- 单独使用 -->
            <select lay-search lay-verify="required" lay-verType="tips" class="layui-input">
                <option value="1">紧急</option>
                <option value="2">高</option>
                <option value="3" selected="selected">中</option>
                <option value="4">低</option>
            </select>
            <input
                type="text" 
                style="width:200px;display:inline-block"
                lay-verify="required" lay-verType="tips"
                class="layui-input" 
                id="datePicker-a"
                placeholder="">
            </input>
            <input
                type="text" 
                style="width:200px;display:inline-block"
                lay-verify="required" lay-verType="tips"
                class="layui-input" 
                id="datePicker-b"
                placeholder="">
            </input>
          <div style="display:inline-block" lay-verify="mustChecked" lay-verType="tips">
              <input type="checkbox" name="checkedOne" title="写作"></input>
              <input type="checkbox" name="checkedOne" title="阅读"></input>
              <input type="checkbox" name="checkedOne" title="发呆"></input>
          </div>
          <input style="width:200px;display:inline-block" name="addChildTaskExpectHours" lay-verify="number" lay-verType="tips" class="layui-input" placeholder=""></input>
          <input style="width:200px;display:inline-block" name="addChildTaskExpectHours" lay-verify="number" lay-verType="tips" class="layui-input" placeholder=""></input>
          <!-- 组件使用 -->
          <div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4">
            <div class="layui-form-item">
                <label class="layui-form-label">物料分类</label>
                <div class="layui-input-block">
                    <input 
                        id="test"
                        style="width:200px;display:inline-block"
                        lay-verify="required" 
                        lay-verType="tips" 
                        class="layui-input" 
                        onclick="formHtmlRender.openMeterialTypeModal('url', 'test')"
                        placeholder=""></input>
                    <input id="testhidden" name=""  type="text"></input>
                </div>
            </div>
          </div>
          <div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4">
              <div class="layui-form-item">
                  <label class="layui-form-label">隐藏</label>
                  <div class="layui-input-block">
                      <input type="text" style="display: none"></input>
                  </div>
              </div>
          </div>
          <div class="layui-col-xs12 layui-col-sm12 layui-col-md12 layui-col-lg12">
              <div class="layui-form-item">
                  <label class="layui-form-label">复选框</label>
                  <div class="layui-input-block">
                      <input type="checkbox" lay-filter="mustChoose" lay-verify="mustChecked" lay-verType="tips" name="checkedOne" title="写作"></input>
                      <input type="checkbox" lay-filter="mustChoose" lay-verify="mustChecked" lay-verType="tips" name="checkedOne" title="阅读"></input>
                      <input type="checkbox" lay-filter="mustChoose" lay-verify="mustChecked" lay-verType="tips" name="checkedOne" title="发呆"></input>
                  </div>
              </div>
          </div>
          <div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4">
              <div class="layui-form-item">
                  <label class="layui-form-label">数字</label>
                  <div class="layui-input-block">
                      <input name="addChildTaskExpectHours" lay-verify="required|number" lay-verType="tips" class="layui-input" id="addChildTaskExpectHours" placeholder=""></input>
                  </div>
              </div>
          </div>
          <div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4">
              <div class="layui-form-item">
                  <label class="layui-form-label">非空</label>
                  <div class="layui-input-block">
                      <input type="text" lay-verify="required" lay-verType="tips" name="addChildTaskName" class="layui-input" id="addChildTaskName" placeholder=""></input>
                  </div>
              </div>
          </div>
          <div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4">
              <div class="layui-form-item">
                  <label class="layui-form-label">邮箱</label>
                  <div class="layui-input-block">
                      <input type="text" lay-verify="required|email" lay-verType="tips" name="myEmail" class="layui-input" id="addChildTaskName" placeholder=""></input>
                  </div>
              </div>
          </div>
          <div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4">
              <div class="layui-form-item addChildTaskLevel">
                  <label class="layui-form-label">下拉选择</label>
                  <div class="layui-input-block">
                      <select lay-search lay-verify="required" lay-verType="tips" class="layui-input" style="width:100%">
                          <option value="">请选择子任务优先等级</option>
                          <option value="1">紧急</option>
                          <option value="2">高</option>
                          <option value="3">中</option>
                          <option value="4">低</option>
                      </select>
                  </div>
              </div>
          </div>
          <div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4">
              <div class="layui-form-item">
                  <label class="layui-form-label">下拉多选</label>
                  <div class="layui-input-block">
                      <select xm-select="city" xm-select-type="2" xm-select-search xm-select-height="38px">
                          <option value=""></option>
                          <option value="1" selected="selected">北京</option>
                          <option value="2">上海</option>
                          <option value="3">苏州</option>
                          <option value="4">天津</option>
                          <option value="5">信阳</option>
                      </select>
                  </div>
              </div>
          </div>
          <div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4">
            <div class="layui-form-item">
                <label class="layui-form-label">下拉多选</label>
                <div class="layui-input-block">
                    <select xm-select="select6" xm-select-type="2" xm-select-search xm-select-height="38px">
                        
                    </select>
                </div>
            </div>
          </div>
          <div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4">
              <div class="layui-form-item">
                  <label class="layui-form-label">时间选择</label>
                  <div class="layui-input-block">
                      <!-- <input
                          type="text" 
                          lay-verify="required" lay-verType="tips"
                          class="layui-input" 
                          id="datePicker"
                          placeholder="">
                      </input> -->
                  </div>
              </div>
          </div>
          <div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4">
              <div class="layui-form-item">
                  <label class="layui-form-label">多项验证</label>
                  <div class="layui-input-block">
                      <input 
                          type="text"
                          lay-verify="required|username" lay-verType="tips"
                          name="addChildTaskIntroduceBy" 
                          class="layui-input" 
                          id="addChildTaskIntroduceBy" placeholder="自定义验证"></input>
                  </div>
              </div>
          </div>
          <div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4">
              <div class="layui-form-item">
                  <label class="layui-form-label">单选框</label>
                  <div class="layui-input-block">
                      <input type="radio" name="sex" value="男" title="男">
                      <input type="radio" name="sex" value="女" title="女" checked>
                  </div>
              </div>
          </div>
          <div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4">
              <div class="layui-form-item">
                  <label class="layui-form-label">开关</label>
                  <div class="layui-input-block">
                      <input type="checkbox" name="switch" lay-skin="switch">
                  </div>
              </div>
          </div>
          <div class="layui-form-item areaForm">
              <label class="layui-form-label">选择地区</label>
              <div class="layui-input-inline">
                  <select name="provid" id="provid" lay-filter="provid" lay-search>
                  </select>
              </div>
              <div class="layui-input-inline">
                  <select name="cityid" id="cityid" lay-filter="cityid" lay-search>
                  </select>
              </div>
              <div class="layui-input-inline">
                  <select name="areaid" id="areaid" lay-filter="areaid" lay-search>
                  </select>
              </div>
          </div>
          <div class="layui-form-item areaForm">
              <label class="layui-form-label">选择地区 -2</label>
              <div class="layui-input-inline">
                  <select name="provid2" id="provid2" lay-filter="provid2" lay-search>
                  </select>
              </div>
              <div class="layui-input-inline">
                  <select name="cityid2" id="cityid2" lay-filter="cityid2" lay-search>
                  </select>
              </div>
              <div class="layui-input-inline">
                  <select name="areaid2" id="areaid2" lay-filter="areaid2" lay-search>
                  </select>
              </div>
          </div>
          
          <div class="fileUpload" style="display:inline-block">
            <button type="button" class="layui-btn" id="fileUpload-1">
                <i class="layui-icon">&#xe67c;</i>文件上传
            </button>
            <input type="hidden" value="" name="" data-name="fileUpload-1"></input>
            <input type="hidden" value="" name="" data-path="fileUpload-1"></input>
            <a href="/common/download/" target="_blank" style="text-decoration: none;margin-left:10px">已上传文件</a>
          </div>
          <div class="fileUpload" style="display:inline-block">
                <button type="button" class="layui-btn" id="fileUpload-1">
                    <i class="layui-icon">&#xe67c;</i>文件上传
                </button>
                <input type="hidden" value="" name="" data-name="fileUpload-1"></input>
                <input type="hidden" value="" name="" data-path="fileUpload-1"></input>
                <a href="/common/download/" target="_blank" style="text-decoration: none;margin-left:10px">已上传文件</a>
              </div>

          <div class="layui-col-xs12 layui-col-sm12 layui-col-md12 layui-col-lg12">
              <div class="layui-form-item">
                  <label class="layui-form-label">子任务描述</label>
                  <div class="layui-input-block">
                      <textarea style="width:100%;height:210px;">
                      
                      </textarea>    
                  </div>
              </div>
          </div>
          <div class="layui-row">
              <button onclick="formHtmlRender.formSaveHandler(2)" type="button" class="layui-btn layui-btn-normal layui-btn-sm">
                  保存
              </button>
              <button lay-submit lay-filter="formDemo" onclick="formHtmlRender.formSubmitHandler(1)" type="submit" class="layui-btn layui-btn-normal layui-btn-sm">
                  提交
              </button>
              <button onclick="" type="button" class="layui-btn layui-btn-primary layui-btn-sm" style="margin-left:10px">
                  重置
              </button>
          </div>
          <button class="layui-btn layui-btn-normal layui-btn-sm" onclick="formHtmlRender.isEdit">编辑</button>
          <div id="toggleShowBtnGroup">
            <button onclick="formHtmlRender.formSaveHandler(2)" type="button" class="layui-btn layui-btn-normal layui-btn-sm">
                保存
            </button>
            <button lay-submit lay-filter="formDemo" onclick="formHtmlRender.formSubmitHandler(1)" type="submit" class="layui-btn layui-btn-normal layui-btn-sm">
                提交
            </button>
          </div>
          <hr>
          <div class="placePicker" style="display:inline-block">
            <select 
                data-url="http://118.178.94.163:6080/qiantu-scms/manager/basedata/area/getAreaByParentId/"
                lay-search lay-verify="required" lay-verType="tips" 
                lay-filter="country-1" id="country-1" class="layui-input">
                <option value="">请选择国家</option>
                <option value="49">中国</option>
            </select>
            <select 
                data-url="http://118.178.94.163:6080/qiantu-scms/manager/basedata/area/getAreaByParentId/"
                lay-search lay-verify="required" lay-verType="tips" 
                lay-filter="province-1" id="province-1" class="layui-input">
                
            </select>
            <select 
                lay-search lay-verify="required" lay-verType="tips" 
                lay-filter="city-1" id="city-1" class="layui-input">
                
            </select>
            <input name="" class="hiddena" type="hidden" value="" />
          </div>
        </form>
        <form action="">
            <q-field class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
                <q-input
                    name="test"
                    float-label="$t('阶段编码')"
                    value="aaa"></q-input>
            </q-field>
        </form>
      </q-step>
      <q-step name="supplierApproval" title="供应商审批" disable>
            
      </q-step>
    </q-stepper>
  </div>
    <!-- ie-polyfill 、 vue.js and quasar-framework -->
    <script src="../lib/js/quasar.ie.polyfills.umd.min.js"></script>
    <script src="../lib/js/vue.js"></script>
    <script src="../lib/js/quasar.mat.umd.min.js"></script>
    <script src="../lib/js/jquery-2.2.4.min.js"></script>
    <script src="../script/consts.js"></script>
    <script src="../lib/layui/layui.js"></script>
    <script src="../lib/jilian/data.js"></script>
    <script src="../lib/jilian/province.js"></script>
    <script src="../lib/js/jquery.form.js"></script>
    <!-- yn-tree -->
    <!-- 源码已被修改 取消反选、全选  去除所有父节点的checkbox 详情在源码里有备注 -->
    <script src="../lib/ynTree/ynTree.js"></script>

    <script>
        // quasar components use
        // Quasar.i18n.set(Quasar.i18n[LANGUGE])
        new Vue({
          el: '#test-stepper',
          data: function() {
            return {
              currentStep: 'supplierRegiste',
              test: ''
            }
          }
        })
    </script>
    <script type="text/javascript">
       
        var currentLayer
        $(document).ready(function() {

            layui.config({
                base: '../lib/js/'
            }).extend({
                formSelects: 'formSelects-v3'
            }).use(['form', 'layer', 'laydate', 'upload', 'formSelects', 'laytpl'], function() {
                var form = layui.form
                var laydate = layui.laydate
                var layer = layui.layer
                var upload = layui.upload
                var formSelects = layui.formSelects
                var laytpl = layui.laytpl
                
                
                $('input').map(function(index, item) {
                    var _id = $(item).attr('id')
                    if (_id != undefined || _id != null) {
                        if (_id.indexOf('datePicker-') > -1) {
                            console.log(_id)
                            //执行一个laydate实例
                            laydate.render({
                                elem: '#' + _id, //指定元素
                                type: 'datetime'
                            })
                        }
                    }
                })
                // 执行 三级级联
                $('.placePicker').map(function(index, item) { // 取得包裹元素
                    var country = '', province = '', city = ''  // 国家省份城市 选择的值
                    var place = ''  // 三者合并的值
                    // 如果有值  则回显
                    var hiddenInput = $(item).find('input[type="hidden"]')
                    if ($(hiddenInput).val()!=undefined && $(hiddenInput).val()!=null) {
                        country = $(hiddenInput).val().split(',')[0]
                        province = $(hiddenInput).val().split(',')[1]
                        city = $(hiddenInput).val().split(',')[2]
                    }
                    $(item).find('select').map(function(index2, item2) {  // 遍历select
                        var _selector = $(item2).attr('lay-filter')
                        var _filter = 'select(' + _selector +')'
                        var _num = _selector.split('-')[1]  // 记录id后的随机数
                        if (_selector.indexOf('country-') > -1) { // 不同层不同事件
                            if (country != '') {
                                // 取得回显国家下 省份的值 
                                $('#'+_selector).val(country).trigger('change')
                                $.ajax({
                                    type: 'post',
                                    url:  $('#'+_selector).attr('data-url') + country,
                                    dataType: 'json',
                                    contentType: 'application/json;charset=utf-8',
                                    success: function(data) {
                                        if (data.length > 0) {
                                            var _optionHtml = '<option value="">请选择省份</>'
                                            data.map(function(province) {
                                                _optionHtml += '<option value="' + province.id + '">'
                                                _optionHtml +=    province.name
                                                _optionHtml += '</option>'
                                            })
                                            $('#province-' + _num).html(_optionHtml)
                                            // 回显省份
                                            $('#province-' + _num).val(province).trigger('change')
                                        } else {
                                            $('#province-' + _num).html('<option value="">无可选的省份</option>')
                                            $('#city-' + _num).html('<option value="">无可选的城市</option>')
                                        }
                                        form.render('select')
                                    },
                                    error: function(err) {

                                    }
                                })
                           }
                            // 监听国家的变化  取得对应的省份
                            form.on(_filter, function(data){  
                                country = data.value
                                $.ajax({
                                    type: 'post',
                                    url: $(data.elem).attr('data-url') + data.value,
                                    dataType: 'json',
                                    contentType: 'application/json;charset=utf-8',
                                    success: function(data) {
                                        if (data.length > 0) {
                                            var _optionHtml = '<option value="">请选择省份</>'
                                            data.map(function(province) {
                                                _optionHtml += '<option value="' + province.id + '">'
                                                _optionHtml +=    province.name
                                                _optionHtml += '</option>'
                                            })
                                            $('#province-' + _num).html(_optionHtml)
                                        } else {
                                            $('#province-' + _num).html('<option value="">无可选的省份</option>')
                                            $('#city-' + _num).html('<option value="">无可选的城市</option>')
                                        }
                                        form.render('select')
                                    },
                                    error: function(err) {

                                    }
                                })
                                place = country + ',' + '' + ',' + ''
                                // 将当前选择的赋值给隐藏的Input
                                formHtmlRender.placeValue(place, item)
                            })
                        }
                        if (_selector.indexOf('province-') > -1) { // 不同层不同事件
                            if (province != '') {
                                // 取得回显国家下 省份的值 
                                $('#'+_selector).val(province).trigger('change')
                                $.ajax({
                                    type: 'post',
                                    url:  $('#'+_selector).attr('data-url') + province,
                                    dataType: 'json',
                                    contentType: 'application/json;charset=utf-8',
                                    success: function(data) {
                                        if (data.length > 0) {
                                            var _optionHtml = '<option value="">请选择城市</>'
                                            var __selector = '#' + _selector
                                            data.map(function(city) {
                                                _optionHtml += '<option value="' + city.id + '">'
                                                _optionHtml +=    city.name
                                                _optionHtml += '</option>'
                                            })
                                            $('#city-' + _num).html(_optionHtml)
                                            // 回显城市
                                            $('#city-' + _num).val(city).trigger('change')
                                        } else {
                                            $('#city-' + _num).html('<option value="">无可选的城市</option>')
                                        }
                                        form.render('select')
                                    },
                                    error: function(err) {

                                    }
                                })
                            }
                            form.on(_filter, function(data){  
                                province = data.value
                                $.ajax({
                                    type: 'post',
                                    url: $(data.elem).attr('data-url') + data.value,
                                    dataType: 'json',
                                    contentType: 'application/json;charset=utf-8',
                                    success: function(data) {
                                        if (data.length > 0) {
                                            var _optionHtml = '<option value="">请选择城市</>'
                                            var __selector = '#' + _selector
                                            data.map(function(city) {
                                                _optionHtml += '<option value="' + city.id + '">'
                                                _optionHtml +=    city.name
                                                _optionHtml += '</option>'
                                            })
                                            $('#city-' + _num).html(_optionHtml)
                                        } else {
                                            $('#city-' + _num).html('<option value="">无可选的城市</option>')
                                        }
                                        form.render('select')
                                    },
                                    error: function(err) {

                                    }
                                })
                                place = country + ',' + province + ',' + ''
                                // 将当前选择的赋值给隐藏的Input
                                formHtmlRender.placeValue(place, item)
                            })
                        }
                        if (_selector.indexOf('city-') > -1) { // 不同层不同事件
                            form.on(_filter, function(data){  
                                city = data.value
                                place = country + ',' + province + ',' + city
                                // 将当前选择的赋值给隐藏的Input
                                formHtmlRender.placeValue(place, item)
                            })
                        }
                    })
                
                })
                //执行实例 文件上传
                $('.fileUpload').map(function(index, item) {
                  $(item).find('button').map(function(index2, item2) {
                    var _selector = $(item2).attr('id')
                    upload.render({
                      elem: '#' + _selector,
                      url: baseURL + '/manager/apqp/index/uploadOperateNew', //上传接口
                      method: 'post',
                      field: 'files',
                      accept: 'file',
                      done: function(data){
                        //上传完毕回调
                        console.log(data)
                        var downloadUrl = '', downloadName = ''
                        if (data.path != null && data.name != null) {
                            var _filename = encodeURI(encodeURIComponent(data.path.split('.')[0]))
                            downloadUrl = baseURL + '/common/download/' + _filename + '/' + data.path.split('.')[1]
                            downloadName = data.name
                        } 
                        // $('input[data-name='+_selector+']').val(data.name)
                        $('input[data-path='+_selector+']').val(downloadUrl)
                        layer.msg('上传成功', {icon: 6})
                        $(item).find('a').attr('href', downloadUrl)
                        $(item).find('a').html(downloadName)
                      },
                      error: function(){
                      //请求异常回调
                      }
                    })
                  })
                })
                // 自定义验证 
                form.verify({
                    username: function(value, item){ //value：表单的值、item：表单的DOM对象
                        if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
                            return '用户名不能有特殊字符';
                        }
                        if(/(^\_)|(\__)|(\_+$)/.test(value)){
                            return '用户名首尾不能出现下划线\'_\'';
                        }
                        if(/^\d+\d+\d$/.test(value)){
                            return '用户名不能全为数字';
                        }
                    },
                    mustChecked: function(value, item) {
                        var elem = $(item).find('div.layui-form-checked')
                        if (elem.length == 0) {
                            return '至少选中一项'
                        }
                    },
                    phone: function(value, item) {
                        if(!/^[1][3,4,5,6,7,8][0-9]{9}$/.test(value)){
                            return '手机号码格式有误';
                        }
                    },
                    fax: function(value, item) {
                        if (!/^(\d{3,4}-)?\d{7,8}$/.test(value)) {
                            return '传真格式有误'
                        }
                    },
                    number: function(value, item) {
                        if (!/^\d+(\.\d+)?$|^$/.test(value)) {
                            return '只能填写数字'
                        }
                    }
                })

                formSelects.render({
                    name: 'select6',
                    data: {
                        arr: [
                            {
                                name: '分组名称1',
                                arr: [
                                    {name: '全选', val: 1, selected: false, disabled: false},	//如果你这么写, 那就不可选不可删.
                                    {name: '全不选', val: 2, selected: true, disabled: true},	//init的优先级高于sel
                                    {name: '反选', arr: [
                                        { name: '第三层 - 1', val: 22, selected: true, disabled: true}
                                    ]},
                                ]
                            },{
                                name: '分组名称2',
                                arr: [
                                    {name: '还有啥', val: 4, selected: false, disabled: false},
                                    {name: '没了吧', val: 5, selected: false, disabled: false},
                                ]
                            },
                        ],
                    }
                });
                // 修改驳回按钮
                $('button').map(function(i,item) {
                    if ($(item).text().trim() === '驳回') {
                        $(item).attr('type', 'submit')
                        $(item).attr('lay-submit', '')
                        $(item).attr('onclick', '')
                        $(item).on('click', formHtmlRender.formSubmitHandler(1))
                    }
                })
                form.render()
            })
        })
        var formHtmlRender = {
            formSubmitHandler: function(arg) {
                $('#addChildTaskForm').ajaxForm({
                    type: 'post',
                    dataType: 'json',
                    data: {
                        // userToken: TOKEN.userToken,
                    },
                    success: function(){
                        alert(111)
                    },
                    error: function() {
                        alert(2222)
                    }
                })
            },
            formSaveHandler: function(arg) {
                $('#addChildTaskForm').ajaxSubmit({
                    type: 'post',
                    dataType: 'json',
                    data: {
                        // userToken: TOKEN.userToken,
                    },
                    success: function(){
                        alert(1)
                    },
                    error: function() {
                        alert(2)
                    }
                })
            },
            openMeterialTypeModal: function(url, id) {
                layui.use(['layer'], function() {
                    var layer = layui.layer
                    var meterialData = [
                        {
                            name: "系统管理",
                            value: "系统管理",
                            children: [
                                {
                                    name: "用户管理",
                                    value: "用户管理",
                                    datas: {},
                                    // children: [
                                    //     {
                                    //         name: "添加用户",
                                    //         value: "添加用户",
                                    //     },
                                    //     {
                                    //         name: "查看用户",
                                    //         value: "查看用户"
                                    //     },
                                    //     {
                                    //         name: "编辑用户",
                                    //         value: "编辑用户",
                                    //         children: [
                                    //             {
                                    //                 name: "删除用户",
                                    //                 value: "删除用户"
                                    //             },
                                    //             {
                                    //                 name: "修改用户",
                                    //                 value: "修改用户",
                                    //                 checked: false
                                    //             }
                                    //         ]
                                    //     }
                                        
                                    // ]
                                },
                                {
                                    name: "投诉管理",
                                    inputName: "complaint",
                                    value: "投诉管理",
                                    checked: false,
                                    // children: [
                                    //     {
                                    //         name: "添加投诉",
                                    //         inputName: "complaint",
                                    //         value: "添加投诉"
                                    //     },
                                    //     {
                                    //         name: "删除投诉",
                                    //         inputName: "complaint",
                                    //         value: "删除投诉"
                                    //     },
                                    //     {
                                    //         name: "编辑投诉",
                                    //         inputName: "complaint",
                                    //         value: "编辑投诉"
                                    //     },
                                    //     {
                                    //         name: "查看投诉",
                                    //         inputName: "complaint",
                                    //         value: "查看投诉"
                                    //     }
                                    // ]
                                }
                            ]
                        },
                        {
                            name: "我的公司",
                            inputName: "company",
                            value: "我的公司",
                            children: [
                                {
                                    name: "公司管理",
                                    inputName: "company manage",
                                    value: "公司管理"
                                },
                                {
                                    name: "部门管理",
                                    inputName: "department manage",
                                    value: "部门管理"
                                }
                            ]
                        }
                    ]
                    // $.ajax({
                    //     type: 'GET',
                    //     url: baseURL + url,
                    //     dataType: 'json',
                    //     async: false,
                    //     contentType: 'application/json;charset=utf-8',
                    //     success: function(data) {
                    //         meterialData = data
                    //     },
                    //     error: function(err) {
                    //       console.log(err);
                    //     }
                    // })
                    currentLayer = layer.open({
                        type: 1,
                        title: '物料分类',
                        skin: 'layui-layer-rim', //加上边框
                        area: ['50%',"80%"], //宽高
                        content: 
                        '<div style="padding:15px">'+
                            '<div class="layui-row">'+
                                '<div style="margin-left:15px">'+
                                    '<button id="saveTo" class="layui-btn layui-btn-normal layui-btn-sm">保存</button>'+
                                    '<button id="close" class="layui-btn layui-btn-primary layui-btn-sm">取消</button>'+
                                '</div>'+
                            '</div>'+
                            '<div id="tree" class=" fl tree" style="margin-top:15px"></div>'+
                        '</div>',
                        success: function() {
                            var currentData
                            var selectorName = '#' + id
                            var selectorIds = '#' + id + 'hidden'
                            var options = {
                                checkStrictly: true,
                                data: meterialData,
                                onchange: function(i, obj) {
                                }
                            };
                            var meterialTree = new YnTree( document.getElementById('tree'), options)
                            // 设置默认选中 
                            if ($(selectorIds).val()) {
                                $(selectorIds).val().split(',').map(function(item) {
                                    meterialTree.select(item, true)
                                })
                            }
                            $('#saveTo').on('click', function() {
                                // 取得选中的Id
                                var selectedIds = meterialTree.getValues()
                                // 遍历取得已选name 
                                var selected = meterialTree.getCheckedInputs()
                                var selectedName = []
                                selected.map(function(item) {
                                    selectedName.push($(item).attr('value'))
                                })
                                $(selectorName).val(selectedName.join(','))
                                $(selectorIds).val(selectedIds.join(','))
                                layer.close(currentLayer)
                            })
                            $('#close').on('click', function() {
                                layer.close(currentLayer)
                            })
                        }
                    })
                })
            },
            isEdit: function() {
                $('#toggleShowBtnGroup').show()
            },
            // 级联 赋值
            placeValue: function(place, item) {
                $(item).find('input[type="hidden"]').map(function(ind, item) {
                    var _selector = $(item).attr('class')
                    if (_selector.indexOf('hidden') > -1) {
                        $('.'+_selector).val(place)
                    }
                })
            }
        }
    </script>
</body>
</html>